package day04;

import day04.utils.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.Connection;

public class Demo05Money {
    public static void main(String[] args)throws Exception {
        //1.创建QueryRunner对象
        QueryRunner qr = new QueryRunner();
        //2.获取连接
        Connection conn = DruidUtils.getConnection();
        //3.准备sql
        String outMoney = "update account set money = money-? where name = ?";
        String inMoney = "update account set money = money+? where name = ?";
        //4.执行sql
        qr.update(conn,outMoney,1000,"taoge");

        //System.out.println(1/0);

        qr.update(conn,inMoney,1000,"yixing");
        //5.关闭资源
        DruidUtils.close(conn,null,null);
    }

}
